<html>
<head><meta charset="utf-8"><title>Lack of completion in impl block · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Lack.20of.20completion.20in.20impl.20block.html">Lack of completion in impl block</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="225848929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Lack%20of%20completion%20in%20impl%20block/near/225848929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Lack.20of.20completion.20in.20impl.20block.html#225848929">(Feb 10 2021 at 15:04)</a>:</h4>
<p>Hello! </p>
<p>I recently started doing some things for regex simplification in my project, however, i noticed something slightly odd. RA seems to kind of just give up on anything in this impl block i have as you can see from the red lines. Is it intentional? it's a bit annoying for me. <a href="/user_uploads/4715/njhLlS7nL-oZW5Ai7t0ljm13/Screenshot_1960.png">Screenshot_1960.png</a> </p>
<div class="message_inline_image"><a href="/user_uploads/4715/njhLlS7nL-oZW5Ai7t0ljm13/Screenshot_1960.png" title="Screenshot_1960.png"><img src="/user_uploads/4715/njhLlS7nL-oZW5Ai7t0ljm13/Screenshot_1960.png"></a></div><p>the visitor macro is simply:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="fm">macro_rules!</span><span class="w"> </span><span class="n">visitor</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="p">(</span><span class="cp">$regex</span>:<span class="nc">expr</span><span class="p">,</span><span class="w"> </span><span class="cp">$src</span>:<span class="nc">expr</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">struct</span> <span class="nc">Visitor</span><span class="o">&lt;'</span><span class="na">a</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="n">ran</span>: <span class="kt">bool</span><span class="p">,</span><span class="w"></span>
<span class="w">            </span><span class="cp">#[allow(dead_code)]</span><span class="w"></span>
<span class="w">            </span><span class="n">src</span>: <span class="kp">&amp;</span><span class="o">'</span><span class="na">a</span> <span class="kt">str</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">new</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Visitor</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="n">ran</span>: <span class="nc">false</span><span class="p">,</span><span class="w"></span>
<span class="w">            </span><span class="n">src</span>: <span class="cp">$src</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="p">};</span><span class="w"></span>
<span class="w">        </span><span class="n">new</span><span class="p">.</span><span class="n">visit_regex</span><span class="p">(</span><span class="cp">$regex</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="k">return</span><span class="w"> </span><span class="n">new</span><span class="p">.</span><span class="n">ran</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="p">};</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="225849064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Lack%20of%20completion%20in%20impl%20block/near/225849064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Lack.20of.20completion.20in.20impl.20block.html#225849064">(Feb 10 2021 at 15:05)</a>:</h4>
<p>try moving the impl out of the function</p>



<a name="225849180"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Lack%20of%20completion%20in%20impl%20block/near/225849180" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Lack.20of.20completion.20in.20impl.20block.html#225849180">(Feb 10 2021 at 15:06)</a>:</h4>
<p>Right, impls outside of functions work, however, i can't really move this impl outside</p>



<a name="225849300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Lack%20of%20completion%20in%20impl%20block/near/225849300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Lack.20of.20completion.20in.20impl.20block.html#225849300">(Feb 10 2021 at 15:07)</a>:</h4>
<p>It may be fixed in the near future</p>



<a name="225849730"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Lack%20of%20completion%20in%20impl%20block/near/225849730" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Lack.20of.20completion.20in.20impl.20block.html#225849730">(Feb 10 2021 at 15:10)</a>:</h4>
<p>I see, i was just wondering if this is a bug</p>



<a name="225849802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Lack%20of%20completion%20in%20impl%20block/near/225849802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Lack.20of.20completion.20in.20impl.20block.html#225849802">(Feb 10 2021 at 15:10)</a>:</h4>
<p>Local items are not supported very well in the latest release</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>